import React from "react";
import { IdeaItem, MyNavBar } from "../../../components";
import { useNavigate } from "react-router-dom";
import { useRequest } from "ahooks";
import { getMyAdoptedCommentList } from "../../../api/my";
import EmptyPage from "../../../components/emptyPage";

//  我的被采纳的建议 数据类型
interface AdoptIdeaRawState {
  releaseUserId: number; //病友圈发布用户id
  releaseUserNickName: string; //病友圈发布用户昵称
  releaseUserHeadPic: string; // 病友圈发布用户头像
  title: string; //病友圈 标题
  disease: string; //主要病症
  adoptTime: number; //我的建议内容
  content: string; //采纳时间
}

const Index: React.FC = () => {
  const navigate = useNavigate();
  const { data: myAdoptedCommentList = [] } = useRequest(async () => {
    const resp = await getMyAdoptedCommentList(1, 3, 1, "1");
    return resp.result;
  });
  return (
    <div>
      {myAdoptedCommentList.length > 0 ? (
        <div>
          <div className="navbar">
            <MyNavBar
              title="被采纳建议"
              leftArrow
              onClickLeft={() => navigate("/my")}
            ></MyNavBar>
          </div>
          {myAdoptedCommentList.length !== 0 &&
            myAdoptedCommentList.map((item: AdoptIdeaRawState) => {
              return <IdeaItem item={item}></IdeaItem>;
            })}
        </div>
      ) : (
        <EmptyPage
          path="/my"
          title="被采纳建议"
          desc="暂无被采纳意见"
        ></EmptyPage>
      )}
    </div>
  );
};

export default Index;
